package com.opo5.logisticsmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.opo5.logisticsmanagement.dao.AddressDao;
import com.opo5.logisticsmanagement.dao.DepotDao;
import com.opo5.logisticsmanagement.domain.Address;
import com.opo5.logisticsmanagement.domain.Depot;
import com.opo5.logisticsmanagement.domain.Locator;
import com.opo5.logisticsmanagement.service.AddressService;
import com.opo5.logisticsmanagement.service.DepotService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepotServiceImpl extends ServiceImpl<DepotDao, Depot> implements DepotService {

    @Autowired
    private DepotDao depotDao;

    @Override
    public IPage<Depot> getPage(int currentPage, int pageSize, Depot depot) {
        LambdaQueryWrapper<Depot> lqw=new LambdaQueryWrapper<Depot>();
        lqw.eq(Strings.isNotEmpty(depot.getDepotType()),Depot::getDepotType,depot.getDepotType());
        lqw.like(Strings.isNotEmpty(depot.getDepotName()),Depot::getDepotName,depot.getDepotName());
        IPage<Depot> page=new Page<>(currentPage,pageSize);
        depotDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public List<Locator> getLocatorNameByDeoptName(String depotName) {
        return depotDao.getLocatorNameByDeoptName(depotName);
    }


}
